import os
from openai import OpenAI
from JiuTian import get_weather_function, get_weather, run_conv

client = OpenAI(api_key=os.environ.get("DEEPSEEK_API_KEY"),base_url=os.environ.get("DEEPSEEK_BASE_URL"))

available_functions = {
    "get_weather": get_weather
}

tools=[
    {
        "type": "function",
        "function": get_weather_function
    }
]

while True:
    text = input("请输入：")

    if text == "exit" or text == "quit" or text == "stop" or text == "end" or text == "退出":
        break

    messages = [{"role": "user", "content": text}]
    print(run_conv(client,'deepseek-chat',messages,tools=tools, functions_list=available_functions.values()))

print("处理完毕")